# encoding: utf-8

import os
from datetime import timedelta

basedir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))


class BaseConfig(object):
    SECRET_KEY = os.getenv('SECRET_KEY', 'secret string')
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # MAIL_SERVER = os.getenv('MAIL_SERVER')
    # MAIL_PORT_ = 465
    # MAIL_USE_SSL = True
    # MAIL_USERNAME = os.getenv_('_MAIL_USERNAME_')
    # MAIL__PASSWORD = os.getenv_('_MAIL_PASSWORD_')
    # MAIL_DEFAULT_SENDER = ('Bluelog Admin', MAIL_USERNAME)
    #
    BLUELOG_EMAIL = os.getenv('BLUELOG_EMAIL', 'mima@example.com')
    BLUELOG_POST_PER_PAGE = 2
    BLUELOG_MANAGE_POST_PER_PAGE = 5
    BLUELOG_COMMENT_PER_PAGE = 5
    SEND_FILE_MAX_AGE_DEFAULT = timedelta(seconds=1)


class DevelopmentConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'data-dev.db')


class TestingConfig(BaseConfig):
    TESTING = True
    WTF_CSRF_ENABLED = False
    SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'


class ProductionConfig(BaseConfig):
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL', 'sqlite:///' + os.path.join(basedir, 'data.db'))


config = {
    'development': DevelopmentConfig,
    'testing': TestingConfig,
    'production': ProductionConfig
}
